import argparse

class ArgumentParser:
    def __init__(self):
        self.parser = argparse.ArgumentParser(description='Translate English PDF book to Chinese.')
        self.parser.add_argument('--config', type=str, default='utils/config.yaml', help='Configuration file with model and API settings.')
        self.parser.add_argument('--model_type', type=str, required=True, choices=['GLMModel', 'OpenAIModel'], help='The type of translation model to use. Choose between "GLMModel" and "OpenAIModel".')        
        self.parser.add_argument('--model_url', type=str, help='The URL of the ChatGLM model URL.')
        self.parser.add_argument('--timeout', type=int, help='Timeout for the API request in seconds.')
        self.parser.add_argument('--openai_model', type=str, default='gpt-3.5-turbo', help='The model name of OpenAI Model. Required if model_type is "OpenAIModel".')
        self.parser.add_argument('--openai_api_key', type=str, default='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', help='The API key for OpenAIModel. Required if model_type is "OpenAIModel".')
        self.parser.add_argument('--book', type=str,default='utils/test.pdf', help='PDF file to translate.')
        self.parser.add_argument('--file_format', type=str,default='markdown', help='The file format of translated book. Now supporting PDF and Markdown')

    def parse_arguments(self):
        args = self.parser.parse_args()
        if args.model_type == 'OpenAIModel' and not args.openai_model and not args.openai_api_key:
            self.parser.error("--openai_model and --openai_api_key is required when using OpenAIModel")
        return args

#     OpenAIModel:
#     model: "gpt-3.5-turbo"
#     api_key: "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
#
#
# "
#
# GLMModel:
# model_url: "your_chatglm_model_url"
# timeout: 300
#
# common:
# book: "test/test.pdf"
# file_format: "markdown"